package com.thomasmoerman.dci.tmc

trait TransferMoneyContextFactory {
  this: TransactionalMoneySourceProvider with MoneySinkProvider =>
  
  def createTransferMoneyContext(sourceAccountId: Long, destinationAccountId: Long, amount: Double) = 
    new TransferMoneyContext(sourceAccountId, destinationAccountId, amount)
  
  class TransferMoneyContext(val sourceAccountId: Long, val destinationAccountId: Long, amount: Double) {
    
    def execute = {
      val source = getTransactionalMoneySource(sourceAccountId)
      
      val destination = getMoneySink(destinationAccountId)
      
      source.transferMoney(amount, destination)
    }
  
  }
  
}